﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace EZBarTender_Wrapper.SmallLabels
{
	public partial class SmallLabelSelection : Form
	{
		private string _connectionString;

		public SmallLabelSelection()
		{
			InitializeComponent();
		}

		public SmallLabelSelection(string connectionString)
		{
			InitializeComponent();
			_connectionString = connectionString;
		}

		private void SmallLabelSelection_Load(object sender, EventArgs e)
		{
			dataGridViewBatches.DataSource = 
				SmallLabelDataAccess.GetSmallLabelBatches(_connectionString);
		}

		private void buttonSet_Click(object sender, EventArgs e)
		{
			foreach (DataGridViewRow row in dataGridViewBatches.SelectedRows)
			{
				SmallLabelDataAccess.SetSmallLabels(
					_connectionString, 
					row.Cells["BatchNo"].Value.ToString());
			}
		}

		private void buttonUnset_Click(object sender, EventArgs e)
		{
			foreach (DataGridViewRow row in dataGridViewBatches.SelectedRows)
			{
				SmallLabelDataAccess.UnetSmallLabels(
					_connectionString,
					row.Cells["BatchNo"].Value.ToString());
			}
		}

		private void buttonChangeByUpc_Click(object sender, EventArgs e)
		{
			ChangeByUpc changer = new ChangeByUpc(_connectionString);
			changer.ShowDialog();
		}
	}
}
